#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache2/bin:/usr/local/mysql/bin
export PATH
log_path="/usr/local/apache2/logs/"
log_size=`du -s $log_path/error_log|cut -f 1`
if [ $log_size -gt 100000 ];
then
mv $log_path/error_log $log_path/error_log_`date +%Y%m%d`;
touch $log_path/error_log;
fi
num_del=`ls -t $log_path/error*|wc -l`
if [ $num_del -gt 4 ];
then
ls -t $log_path/error*|tail -$[$num_del-2]|xargs -i rm -f {} 2 > /dev/null
fi
exit 0